package com.beidouapp.security.model;

import java.util.List;

public class ExtendReturnDataInfo<T, E> extends ReturnDataInfo<T>
{
	private E extendObj;

	public static <T, E> ExtendReturnDataInfo<T, E> createSuccessfulExecuteResults(List<T> entry, Integer offset, Integer limit, Long totalcount, E extendObj)
	{
		ExtendReturnDataInfo<T, E> info = new ExtendReturnDataInfo<T, E>();
		info.setFlag(true);
		info.setResults(entry);
		info.setLimit(limit);
		info.setOffset(offset);
		info.setTotalcount(totalcount);
		info.setExtendObj(extendObj);
		return info;
	}

	public static <T, E> ExtendReturnDataInfo<T, E> createSuccessfulSingleExecuteResult(T entry, E extendObj)
	{
		ExtendReturnDataInfo<T, E> info = new ExtendReturnDataInfo<T, E>();
		info.setFlag(true);
		info.setResult(entry);
		info.setTotalcount(1l);
		info.setExtendObj(extendObj);
		return info;
	}

	public static <T, E> ExtendReturnDataInfo<T, E> createExtendFailedExecuteResult(String message)
	{
		ExtendReturnDataInfo<T, E> info = new ExtendReturnDataInfo<T, E>();
		info.setFlag(false);
		info.setStatusCode(500);
		info.setMessage(message);
		return info;
	}

	public static <T, E> ExtendReturnDataInfo<T, E> createExtendFailedExecuteResult(Integer statusCode, String message)
	{
		ExtendReturnDataInfo<T, E> info = new ExtendReturnDataInfo<T, E>();
		info.setFlag(false);
		info.setStatusCode(statusCode);
		info.setMessage(message);
		return info;
	}

	public E getExtendObj()
	{
		return extendObj;
	}

	public void setExtendObj(E extendObj)
	{
		this.extendObj = extendObj;
	}
}
